<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

	<h:form id="formGestion">

		<table class="tables">
			<p:growl id="growllge" showDetail="true" life="2000"
				showSummary="false" />
			<tr>
				<td><p:panel toggleable="false" collapsed="false" id="pGestion"
						style="text-align: left;	font-size: 12px; border:none;">

						<h:panelGrid columns="5" styleClass="panelTDBotonFormulario">
							<p:commandButton
								rendered="#{modificarOfertasBean.prodCabeceraProformaModificar.prodEstados.estaId==1}"
								action="#{modificarOfertasBean.consultarTarifGestionGeneralPorBasePresupuestal}"
								immediate="true" value="Agregar gestión y entregables"
								oncomplete="dlgGestion.show()"
								update=":tabView:paindirectos:formGestionDialog:hpgGestion" />

							<p:commandButton rendered="false"
								action="#{modificarOfertasBean.consultarGestionGeneralProforma()}"
								value="Calcular Costos"
								update="opGestionGeneral,dtGestionGeneralTable" immediate="true" />
							<h:outputText
								value="Subtotal de Gestión General y Entregables del Proyecto: " />
							<h:outputText value="#{modificarOfertasBean.simbolo}" />
							<h:outputText
								value="#{modificarOfertasBean.subTotalGestionGeneral}">
								<f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
							</h:outputText>
						</h:panelGrid>


					</p:panel> <p:outputPanel id="opGestionGeneral"
						styleClass="panelTDLeftFormulario">

						<p:dataTable id="dtGestionGeneralTable"
							value="#{modificarOfertasBean.listaGestionGeneralPersonalizado}"
							var="gestion" paginator="true"
							rows="#{modificarOfertasBean.numeroFilasFormularios}"
							editable="true">
							<p:ajax event="rowEdit"
								listener="#{modificarOfertasBean.onEditGestionGeneral}"
								immediate="true"
								update=":tabView:paindirectos:formGestion:growllge,:tabView:paindirectos:formGestion:dtGestionGeneralTable,:tabView:paindirectos:formGestion:pGestion" />
							<p:ajax event="rowEditCancel"
								listener="#{modificarOfertasBean.onCancelGestionGeneral}"
								immediate="true" />


							<p:column headerText="Descripción" style="width:25%">

								<h:outputText
									value="#{gestion.prodGestionGeneralProf.prodTarifGestGenerales.taggDescripcion}" />

							</p:column>
							<p:column headerText="U " style="width:10%">

								<h:outputText
									value="#{gestion.unidad}" />

							</p:column>
							<p:column headerText="Cantidad" style="width:5%"
								styleClass="valoresTabla">
								<p:cellEditor>
									<f:facet name="output">
										<h:outputText
											value="#{gestion.prodGestionGeneralProf.ggprCantidad}">
											<f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
										</h:outputText>
									</f:facet>
									<f:facet name="input">
										<h:inputText
											value="#{gestion.prodGestionGeneralProf.ggprCantidad}">
											<f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
										</h:inputText>
									</f:facet>
								</p:cellEditor>

							</p:column>
							<p:column headerText="Costo Unitario" styleClass="valoresTabla"
								style="width:10%">
								<h:outputText value="#{modificarOfertasBean.simbolo} " />

								<h:outputText
									value="#{gestion.prodGestionGeneralProf.ggprCostoUnitario}">
									<f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
								</h:outputText>
							</p:column>


							<p:column headerText="Factor de Ajuste" styleClass="valoresTabla"
								style="width:10%">
								<p:cellEditor>
									<f:facet name="output">
										<h:outputText
											value="#{gestion.prodGestionGeneralProf.ggprFactorajuste}">
											<f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
										</h:outputText>
									</f:facet>
									<f:facet name="input">
										<h:inputText
											value="#{gestion.prodGestionGeneralProf.ggprFactorajuste}">
											<f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
										</h:inputText>
									</f:facet>
								</p:cellEditor>

							</p:column>
							<p:column headerText="Costo Total" styleClass="valoresTabla"
								style="width:10%">
								<h:outputText value="#{modificarOfertasBean.simbolo} " />

								<h:outputText value="#{gestion.costoTotal}">
									<f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
								</h:outputText>

							</p:column>

							<p:column style="width:6%"
								rendered="#{modificarOfertasBean.prodCabeceraProformaModificar.prodEstados.estaId==1}">
								<f:facet name="header">
									<h:outputText value="E" />
								</f:facet>
								<p:rowEditor />
							</p:column>
							<p:column style="width:6%"
								rendered="#{modificarOfertasBean.prodCabeceraProformaModificar.prodEstados.estaId==1}">
								<f:facet name="header">
									<h:outputText value="X" />
								</f:facet>
								<p:commandButton update="dtGestionGeneralTable" immediate="true"
									label="eliminar" icon="ui-icon-close"
									action="#{modificarOfertasBean.deleteActionGestionGeneral(gestion)}"></p:commandButton>
								<br />
							</p:column>
							<p:column headerText="% G.G." styleClass="valoresTabla"
								style="width:9%">

								<h:outputText value="#{gestion.pgg}">
									<f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
								</h:outputText>

							</p:column>
						</p:dataTable>



					</p:outputPanel></td>
			</tr>
		</table>

	</h:form>
	<p:dialog id="mp_tarifarios" position="top" width="500"
		header="Agregar Gestión y Entregables" appendToBody="true"
		styleClass="pPanel" height="550px" widgetVar="dlgGestion">
		<h:form id="formGestionDialog">
			<h:panelGrid id="hpgGestion" columns="4" cellpadding="1"
				style="margin:0 auto;" width="100%">
				<table width="100%;">

					<tr>
						<td><p:panel width="100%;">
								<table width="100%;">
									<p:growl id="growllGestion" showDetail="true" life="2000"
										showSummary="false" />

									<tr>
										<td colspan="2"><p:dataTable var="tarifa"
												id="tableTarifaGestion"
												value="#{modificarOfertasBean.listaTarifarioGestionPorBasePresupuestal}"
												paginator="true"
												rows="#{modificarOfertasBean.numeroFilasPopup}">
												<p:column style="width:5%;" exportable="false">

													<p:commandButton id="selectButton"
														action="#{modificarOfertasBean.guardarGestionGeneralProforma}"
														immediate="true"
														update=":tabView:paindirectos:formGestion:opGestionGeneral,:tabView:paindirectos:formGestionDialog:growllGestion,:tabView:paindirectos:formGestion:pGestion"
														icon="ui-icon-plusthick" title="Agregar Tarifa">
														<f:setPropertyActionListener value="#{tarifa}"
															target="#{modificarOfertasBean.tarifGestion}" />

													</p:commandButton>
												</p:column>
												<p:column headerText="Descripción"
													filterBy="taggDescripcion" filterMatchMode="contains">
													<h:outputText value="#{tarifa.taggDescripcion}" />
												</p:column>
												<p:column headerText="Costo" styleClass="valoresTabla" style="width:15%">
													<h:outputText value="#{modificarOfertasBean.simbolo} " />
													<h:outputText value="#{tarifa.taggCostoDirectoUnitario}" />
												</p:column>

											</p:dataTable></td>
									</tr>
								</table>
							</p:panel></td>
					</tr>
				</table>
			</h:panelGrid>

		</h:form>
	</p:dialog>

</ui:composition>